import defined from "../../Core/defined.js";
import DeveloperError from "../../Core/DeveloperError.js";
import QuarkGISInspector from "../QuarkGISInspector/QuarkGISInspector.js";

/**
 * A mixin which adds the QuarkGISInspector widget to the Viewer widget.
 * Rather than being called directly, this function is normally passed as
 * a parameter to {@link Viewer#extend}, as shown in the example below.
 * @function
 *
 * @param {Viewer} viewer The viewer instance.
 *
 * @exception {DeveloperError} viewer is required.
 *
 * @demo {@link https://sandcastle.quarkgis.com/index.html?src=QuarkGIS%20Inspector.html|QuarkGIS Sandcastle QuarkGIS Inspector Demo}
 *
 * @example
 * var viewer = new QuarkGIS.Viewer('quarkgisContainer');
 * viewer.extend(QuarkGIS.viewerQuarkGISInspectorMixin);
 */
function viewerQuarkGISInspectorMixin(viewer) {
  //>>includeStart('debug', pragmas.debug);
  if (!defined(viewer)) {
    throw new DeveloperError("viewer is required.");
  }
  //>>includeEnd('debug');

  var quarkgisInspectorContainer = document.createElement("div");
  quarkgisInspectorContainer.className = "quarkgis-viewer-quarkgisInspectorContainer";
  viewer.container.appendChild(quarkgisInspectorContainer);
  var quarkgisInspector = new QuarkGISInspector(
    quarkgisInspectorContainer,
    viewer.scene
  );

  Object.defineProperties(viewer, {
    quarkgisInspector: {
      get: function () {
        return quarkgisInspector;
      },
    },
  });
}
export default viewerQuarkGISInspectorMixin;
